const mongo = require('mongoose');
const config = require('./config.js');
const url = `mongodb://${config.name}:${config.pwd}@${config.url}/${config.dbName}`;
log.info('开始链接数据库')
log.info('链接地址为: ' + url);
const db = mongo.connect(url);
const dbs = mongo.connection;
dbs.on('error', function(err) {
  log.error('数据库链接失败');
  log.error(err);
});
dbs.once('open', function() {
  log.info('数据库链接成功');
});
module.exports = db;